﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

using FormulParserNamespace;

namespace TestForFormulParser
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void label2_Click(object sender, EventArgs e)
        {

        }

        private void Test_Click(object sender, EventArgs e)
        {
            PostfixParserOld parser = new PostfixParserOld( inputString.Text );

            listOfElements.RowCount = parser.GetElements().Count;
            listOfElements.ColumnCount = 1;            
            for (int i = 0; i < listOfElements.RowCount; i++)
            {
                listOfElements.Rows[i].Cells[0].Value = parser.GetElements()[i];
            }

            listOfVariables.RowCount = parser.GetVariables().Count;
            listOfVariables.ColumnCount = 1;
            for (int i = 0; i < listOfVariables.RowCount; i++)
            {
                listOfVariables.Rows[i].Cells[0].Value = parser.GetVariables().ElementAt(i);
            }

            listOfPolish.RowCount = parser.GetPostfix().Count;
            listOfPolish.ColumnCount = 1;
            for (int i = 0; i < listOfPolish.RowCount; i++)
            {
                listOfPolish.Rows[i].Cells[0].Value = parser.GetPostfix().ElementAt(i);
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            FormulParserInterface parser = new PostfixParser(inputString.Text);
            double res = parser.evaluate();
            inputString.Text = res.ToString();
        }
    }
}
